{
  Модуль хранения истории изменения данных проекта

 История изменений
 Внесение изменения
 Откат изменений
 Сравнение версий

   версия 0.2 март 2011 prodg@ya.ru D.Kondakov
}
unit DataHistSystm;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, IIntgrlTypes, IIntgrlBaseCnfg, DataObjcts;

{$i calcconfig.inc}

type

  TElmntHist = class
    constructor Create;
    destructor Destroy; override;
    procedure AddChange;
    procedure FindInChanges;
    procedure GetFullHistory;
  end;

  { TPrjDataHistory }

  TPrjDataHistory = class(TinlModule)
    constructor Create(wCfg: TinlConfiguration);
    destructor Destroy; override;
    procedure GetDefParams(DefParams: TStrings); override;
    function CheckParams: TinlLogicType; override;
    procedure AddDefParams(Params: TStringList); override;
    procedure ResetParams; override;
    procedure ProceedSignal(snlMsg: TinlStringType); override;

    function GetDataLastVer(dID: TinlNameType): TinlModifctn;
    function GetDataCurVer(dID: TinlNameType): TinlModifctn;
    procedure SetDataCurVer(dID: TinlNameType; cVersn: TinlModifctn);
    procedure RollBackDataToVer(dID: TinlNameType; cVersn: TinlModifctn);
  protected
    function GetUnitVersion: TinlModifctn; override;
    procedure DataInit; override;
    procedure DataDone; override;
    function GetModuleType: TModuleType; override;
  private
    FLastVersn: TinlModifctn;
    FCurVersn: TinlModifctn;
    procedure SetCurVersion(const AValue: TinlModifctn);
  public // Специфичные функции
    property LastVersion: TinlModifctn read FLastVersn;
    property CurVersion: TinlModifctn read FCurVersn write SetCurVersion;
    procedure CommitLastChanges;
    procedure RollBackToVersion(OldVersn: TinlModifctn);
    procedure CompareVersions(LeftVersn, RightVersn: TinlModifctn);
  end;

const
  HISTmodVer = 1000001;

implementation

{ TPrjDataHistory }

constructor TPrjDataHistory.Create(wCfg: TinlConfiguration);
begin
  inherited Create(wCfg);

//  ConnectDB;
//  Post(logEMI);
end;

destructor TPrjDataHistory.Destroy;
begin

  inherited;
end;

procedure TPrjDataHistory.GetDefParams(DefParams: TStrings);
begin
  DefParams.Append('HIST_MAX_VERS=Количество хранимых версий');
end;

function TPrjDataHistory.CheckParams: TinlLogicType;
begin
  Result := true;
end;

procedure TPrjDataHistory.AddDefParams(Params: TStringList);
begin
  Params.Append('HIST_MAX_VERS=5');
end;

procedure TPrjDataHistory.ResetParams;
begin
  //inherited ResetParams;
end;

procedure TPrjDataHistory.ProceedSignal(snlMsg: TinlStringType);
begin
  //inherited ProceedSignal(snlMsg);
end;

function TPrjDataHistory.GetDataLastVer(dID: TinlNameType): TinlModifctn;
begin

end;

function TPrjDataHistory.GetDataCurVer(dID: TinlNameType): TinlModifctn;
begin

end;

procedure TPrjDataHistory.SetDataCurVer(dID: TinlNameType; cVersn: TinlModifctn);
begin

end;

procedure TPrjDataHistory.RollBackDataToVer(dID: TinlNameType; cVersn: TinlModifctn
  );
begin

end;

function TPrjDataHistory.GetUnitVersion: TinlModifctn;
begin
  Result := HISTmodVer;
end;

procedure TPrjDataHistory.DataInit;
begin
  //inherited DataInit;
end;

procedure TPrjDataHistory.DataDone;
begin
  //inherited DataDone;
end;

function TPrjDataHistory.GetModuleType: TModuleType;
begin
  Result := mHIST;
end;

procedure TPrjDataHistory.SetCurVersion(const AValue: TinlModifctn);
begin
  if FCurVersn=AValue then exit;
  FCurVersn:=AValue;
end;

procedure TPrjDataHistory.CommitLastChanges;
begin
  //
end;

procedure TPrjDataHistory.RollBackToVersion(OldVersn: TinlModifctn);
begin
  //
end;

procedure TPrjDataHistory.CompareVersions(LeftVersn, RightVersn: TinlModifctn);
begin
  //
end;

constructor TElmntHist.Create;
begin
  inherited Create;

end;

destructor TElmntHist.Destroy;
begin

  inherited;
end;

procedure TElmntHist.AddChange;
begin

end;

procedure TElmntHist.FindInChanges;
begin

end;

procedure TElmntHist.GetFullHistory;
begin

end;

end.

